public class MyCircularQueue {
    public int[] array;
    public int first;
    public int last;
    public MyCircularQueue(int k) {
        array = new int[k+1];
    }
    public boolean enQueue(int value) {
        if(isFull()) {
            return false;
        }
        array[last] = value;
        last = (last+1) % array.length;
        return true;
    }
    public boolean deQueue() {
        if(isEmpty()) {
            return false;
        }
        first = (first + 1) % array.length;
        return true;
    }
    public int Front() {
        if(isEmpty()) {
            return  -1;
        }
        return array[first];
    }
    public int Rear() {
        if(isEmpty()) {
            return -1;
        }
        int index = (last == 0) ? array.length - 1 : last - 1;
        return array[index];
    }
    public boolean isEmpty() {
        return last == first;
    }
    public boolean isFull() {
        return (last+1) % array.length == first;
    }
}